<template>
  <div>
    <el-row :gutter="20">
      <div class="container">
      <el-col :span="12">
        <el-row>
          <el-input v-model="input" placeholder="请输入合同名称" class="chMassage"></el-input>
          <el-date-picker
      v-model="value1"
      type="date"
      placeholder="选择日期" class="chDate">
    </el-date-picker>
          <el-button type="primary" class="inquiry">查询</el-button>
        </el-row>
        <el-table
          :data="tableData"
          style="width: 100%">
          <el-table-column
            prop="date"
            label="日期"
            width="110">
          </el-table-column>
          <el-table-column
            prop="name"
            label="姓名"
            width="90">
          </el-table-column>
          <el-table-column
            prop="massager"
            label="合同名称"
            width="150">
          </el-table-column>
          <el-table-column
            prop="checkPass"
            label="工时"
            width="50">
          </el-table-column>
          <el-table-column
            prop="schedule"
            label="进度"
            width="50">
          </el-table-column>
          <el-table-column
            prop="age"
            label="内容">
          </el-table-column>
        </el-table>
        <el-pagination
        class="pageList"
        :page-sizes="[5,10,15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="counts"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      ></el-pagination>
      </el-col>
      </div>
      <el-col :span="12">
        <el-calendar>
          <!-- 这里使用的是 2.5 slot 语法，对于新项目请使用 2.6 slot 语法-->
          <template
            slot="dateCell"
            slot-scope="{data}">
            <p :class="data.isSelected ? 'is-selected' : ''">
              {{ data.day.split('-').slice(1).join('-') }} {{ data.isSelected ? '✔️' : ''}}
              <br>
              <span v-if="isFriday(data)"  @click="edit(data.day)">点击编辑</span>
            </p>
          </template>
        </el-calendar>
      </el-col>
    </el-row>
    <el-dialog
      title="提示"
      append-to-body
      :visible.sync="dialogVisible"
      width="60%"
    >
      <el-form :model="form" status-icon  label-width="100px" class="demo-ruleForm">
        <el-form-item label="任务名称：" prop="pass">
          <template>
            <el-select v-model="form.taskName" placeholder="请选择">
              <el-option
                v-for="item in taskList"
                :key="item.id"
                :label="item.value"
                :value="item.id">
              </el-option>
            </el-select>
          </template>
        </el-form-item>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="工时：" prop="checkPass">
              <el-input type="password" v-model="form.workTime" autocomplete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <span class="demonstration">进度：</span>
            <el-slider v-model="form.schedule"></el-slider>
          </el-col>
          <el-col :span="6">
            <el-input-number v-model="form.schedule"  :min="1" :max="100"></el-input-number>
          </el-col>
        </el-row>
        <el-form-item label="内容：" prop="age">
          <el-input type="textarea" v-model.number="form.content"></el-input>
        </el-form-item>
        <!--            <el-form-item>-->
        <!--              <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>-->
        <!--              <el-button @click="resetForm('ruleForm')">重置</el-button>-->
        <!--            </el-form-item>-->
      </el-form>
      <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
          </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'WeeklyNewspaper',
  data () {
    return {
      tableData: [],
      dialogVisible: false,
      taskList: [],
      form: {
        taskName: '',
        workTime: '',
        schedule: '',
        content: ''
      },
      inpute: '',
      value1: ''
    }
  },
  created () {
    this.init()
  },
  methods: {
    init () {
      const data = {
        createTime: '2023-07-18',
        data: '一件事情'
      }
      // const date = new Date(data.createTime)
      // data.createTime = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDay()
      this.tableData.push(data)
      const weekDate1 = {
        id: 1,
        value: '测试任务1'
      }
      const weekDate2 = {
        id: 2,
        value: '测试任务2'
      }
      const weekDate3 = {
        id: 3,
        value: '测试任务3'
      }
      this.taskList.push(weekDate1)
      this.taskList.push(weekDate2)
      this.taskList.push(weekDate3)
    },
    isDay (data) {
      // console.log(data.day)
      // eslint-disable-next-line eqeqeq
      const filter = this.tableData.filter(item => item.createTime == data.day)
      // eslint-disable-next-line eqeqeq
      return filter.length != 0
    },
    edit (date) {
      this.dialogVisible = true
    },
    isFriday (date) {
      const date1 = new Date(date.day)
      // eslint-disable-next-line eqeqeq
      return date1.getDay() == 5
    }
  }
}
</script>

<style scoped>
.is-selected {
  color: #1989FA;
}
.el-dialog__wrapper /deep/ .el-dialog {
  box-shadow: none;
}
.chMassage{
  margin-left: 40px;
  margin-top: 30px;
  width: 230px;
}
.chDate{
  margin-left: 40px;
  width: 230px;
}
.inquiry{
  margin-left: 40px;
}
</style>
